package com.snowj.apaas.repository.auto;

import static com.snowj.apaas.repository.auto.ClientsDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.snowj.apaas.domain.auto.Clients;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface ClientsMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.925873+08:00", comments="Source Table: clients")
    BasicColumn[] selectList = BasicColumn.columnList(id, name, address, cellphone, remarks, createdBy, createdDate, lastModifiedBy, lastModifiedDate);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.917078+08:00", comments="Source Table: clients")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.917203+08:00", comments="Source Table: clients")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.917548+08:00", comments="Source Table: clients")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @Options(useGeneratedKeys=true,keyProperty="record.id")
    int insert(InsertStatementProvider<Clients> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.921058+08:00", comments="Source Table: clients")
    @Insert({
        "${insertStatement}"
    })
    @Options(useGeneratedKeys=true,keyProperty="records.id")
    int insertMultiple(@Param("insertStatement") String insertStatement, @Param("records") List<Clients> records);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.921719+08:00", comments="Source Table: clients")
    default int insertMultiple(MultiRowInsertStatementProvider<Clients> multipleInsertStatement) {
        return insertMultiple(multipleInsertStatement.getInsertStatement(), multipleInsertStatement.getRecords());
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.921846+08:00", comments="Source Table: clients")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ClientsResult")
    Optional<Clients> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.921971+08:00", comments="Source Table: clients")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ClientsResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="cellphone", property="cellphone", jdbcType=JdbcType.VARCHAR),
        @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
        @Result(column="created_by", property="createdBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="created_date", property="createdDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_modified_by", property="lastModifiedBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_modified_date", property="lastModifiedDate", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Clients> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.923461+08:00", comments="Source Table: clients")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.923715+08:00", comments="Source Table: clients")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.923846+08:00", comments="Source Table: clients")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.923937+08:00", comments="Source Table: clients")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.924268+08:00", comments="Source Table: clients")
    default int insert(Clients record) {
        return MyBatis3Utils.insert(this::insert, record, clients, c ->
            c.map(name).toProperty("name")
            .map(address).toProperty("address")
            .map(cellphone).toProperty("cellphone")
            .map(remarks).toProperty("remarks")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.924522+08:00", comments="Source Table: clients")
    default int insertMultiple(Collection<Clients> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, clients, c ->
            c.map(name).toProperty("name")
            .map(address).toProperty("address")
            .map(cellphone).toProperty("cellphone")
            .map(remarks).toProperty("remarks")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.925527+08:00", comments="Source Table: clients")
    default int insertSelective(Clients record) {
        return MyBatis3Utils.insert(this::insert, record, clients, c ->
            c.map(name).toPropertyWhenPresent("name", record::getName)
            .map(address).toPropertyWhenPresent("address", record::getAddress)
            .map(cellphone).toPropertyWhenPresent("cellphone", record::getCellphone)
            .map(remarks).toPropertyWhenPresent("remarks", record::getRemarks)
            .map(createdBy).toPropertyWhenPresent("createdBy", record::getCreatedBy)
            .map(createdDate).toPropertyWhenPresent("createdDate", record::getCreatedDate)
            .map(lastModifiedBy).toPropertyWhenPresent("lastModifiedBy", record::getLastModifiedBy)
            .map(lastModifiedDate).toPropertyWhenPresent("lastModifiedDate", record::getLastModifiedDate)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.925961+08:00", comments="Source Table: clients")
    default Optional<Clients> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926046+08:00", comments="Source Table: clients")
    default List<Clients> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.92613+08:00", comments="Source Table: clients")
    default List<Clients> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926204+08:00", comments="Source Table: clients")
    default Optional<Clients> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926295+08:00", comments="Source Table: clients")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, clients, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926374+08:00", comments="Source Table: clients")
    static UpdateDSL<UpdateModel> updateAllColumns(Clients record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(name).equalTo(record::getName)
                .set(address).equalTo(record::getAddress)
                .set(cellphone).equalTo(record::getCellphone)
                .set(remarks).equalTo(record::getRemarks)
                .set(createdBy).equalTo(record::getCreatedBy)
                .set(createdDate).equalTo(record::getCreatedDate)
                .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
                .set(lastModifiedDate).equalTo(record::getLastModifiedDate);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926551+08:00", comments="Source Table: clients")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Clients record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(name).equalToWhenPresent(record::getName)
                .set(address).equalToWhenPresent(record::getAddress)
                .set(cellphone).equalToWhenPresent(record::getCellphone)
                .set(remarks).equalToWhenPresent(record::getRemarks)
                .set(createdBy).equalToWhenPresent(record::getCreatedBy)
                .set(createdDate).equalToWhenPresent(record::getCreatedDate)
                .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
                .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926736+08:00", comments="Source Table: clients")
    default int updateByPrimaryKey(Clients record) {
        return update(c ->
            c.set(name).equalTo(record::getName)
            .set(address).equalTo(record::getAddress)
            .set(cellphone).equalTo(record::getCellphone)
            .set(remarks).equalTo(record::getRemarks)
            .set(createdBy).equalTo(record::getCreatedBy)
            .set(createdDate).equalTo(record::getCreatedDate)
            .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
            .set(lastModifiedDate).equalTo(record::getLastModifiedDate)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.926889+08:00", comments="Source Table: clients")
    default int updateByPrimaryKeySelective(Clients record) {
        return update(c ->
            c.set(name).equalToWhenPresent(record::getName)
            .set(address).equalToWhenPresent(record::getAddress)
            .set(cellphone).equalToWhenPresent(record::getCellphone)
            .set(remarks).equalToWhenPresent(record::getRemarks)
            .set(createdBy).equalToWhenPresent(record::getCreatedBy)
            .set(createdDate).equalToWhenPresent(record::getCreatedDate)
            .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
            .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate)
            .where(id, isEqualTo(record::getId))
        );
    }
}